package uform.model.value;

import utest.Assert;

import uform.model.value.IntType;

class TestFloatType extends Test
{
	public function testParse()
	{
		var value = new FloatType();
		Assert.equals(-1.1, value.parse("-1.1"));
		Assert.equals( 1.1, value.parse("+1.1"));
		Assert.equals( 1.1, value.parse(" 1.1 "));
		Assert.equals(0.1234567, value.parse("0.1234567"));
		Assert.raises(function() value.parse(""), Dynamic);
		Assert.raises(function() value.parse("x"), Dynamic);
		Assert.raises(function() value.parse("y0"), Dynamic);
	}
	
	public function testValidate()
	{
		var value = new FloatType();
		assertValidation(value.validate(-1.0), true);
		assertValidation(value.validate( 0.0), true);
		assertValidation(value.validate( 1.0), true);
	}
	
	public function testValidateType()
	{
		var value = new FloatType();
		assertValidation(value.validateType( 0.0), true);
		assertValidation(value.validateType( 1.0), true);
		assertValidation(value.validateType(-1.0), true);
		assertValidation(value.validateType(true), false);
		assertValidation(value.validateType(""), false);
	}
	
	public function testRender()
	{
		var value = new FloatType();
		Assert.equals( "0.1", value.render( 0.1));
		Assert.equals("-1.1", value.render(-1.1));
		Assert.equals( "1.1", value.render( 1.1));
	}
	
	public function new();
}